package keqiang.com.kq_flutter_core_widget.util.qq;

import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.core.content.FileProvider;

/**
 * qq本地文件分享时文件提供器
 *
 * @author Created by wanggaowan on 2025/4/17 16:07
 */
public class QQFileProvider extends FileProvider {
    @Nullable
    static ProviderInfo getProviderInfo(Context context) {
        try {
            ProviderInfo providerInfo;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                providerInfo = context.getPackageManager().getProviderInfo(new ComponentName(context, QQFileProvider.class), PackageManager.ComponentInfoFlags.of(PackageManager.MATCH_DEFAULT_ONLY));
            } else {
                providerInfo = context.getPackageManager().getProviderInfo(new ComponentName(context, QQFileProvider.class), PackageManager.MATCH_DEFAULT_ONLY);
            }
            return providerInfo;
        } catch (Exception e) {
            return null;
        }
    }
}
